<template>
	<view class="content">
		<nav-header bgColor="bg-custom-color">
			<!-- <block slot="backText">返回</block> -->
			<block slot="content">{{$t('order.lineUpOrder')}}</block>
		</nav-header>

		<view class="padding flex flex-direction back" style="margin-bottom: 60px;">
			<!-- <button class="cu-btn bg-et margin-tb-sm lg" @tap="modalName = 'RadioModal'">排单</button> -->
			<button class="cu-btn bg-et margin-tb-sm lg" @click="$common.toPage('../order/form')">{{$t('order.lineUpOrder')}}</button>
		</view>



		<!-- <view class="cu-modal" :class="modalName=='RadioModal'?'show':''" @tap="hideModal">
			<view class="cu-dialog" @tap.stop="">
				<radio-group class="block">
					<view class="cu-list menu text-left">
						<view class="cu-item" v-for="(item,index) in list" :key="index" @tap="modalChoose(item)">
							<label class="flex justify-between align-center flex-sub">
								<view class="flex-sub">{{item.typeName}}USDT</view>
							</label>
						</view>
					</view>
				</radio-group>
			</view>
		</view> -->

		<view class="cu-modal" :class="isShowModal?'show':''">
			<view class="cu-dialog">
				<view class="cu-bar bg-white justify-end">
					<view class="content">{{$t('order.InformationValidation')}}</view>
					<view class="action" @tap="chanageShowModal">
						<text class="cuIcon-close text-red"></text>
					</view>
				</view>
				<view class="padding-xl">
					<view class="cu-form-group ">
						<view class="title">{{$t('order.DeterminationOfExecution')}}{{entity.typeName}}USDT?</view>
					</view>
				</view>
				<view class="cu-bar bg-white justify-end">
					<view class="action modal-bottom">
						<button class="cu-btn line-green text-green modal-bottom-btn" @tap="chanageShowModal">{{$t('cancel')}}</button>
						<button class="cu-btn bg-green margin-left modal-bottom-btn" @tap="tijiao()">{{$t('sure')}}</button>
					</view>
				</view>
			</view>
		</view>

		<nav-bottom showIndex='3'></nav-bottom>
	</view>


</template>

<script>
	var t;
	export default {
		data() {
			return {
				isShowModal: false,
				modalName: null,
				list: [],
				entity: {},
				userInfo: null,
			}
		},
		onLoad() {
			t = this;
			this.$i18n.locale = t.$common.localRead("local")
			t.userInfo = $common.getUser()
			if (!t.userInfo) {
				$common.notLoginUser()
			}
			console.info(t.userInfo)
			this.getData();
		},
		mounted() {

		},
		methods: {
			getData: function() {
				this.$fetch.request('baseData/list', {
					'type': 50
				}).then((res) => {
					console.info(res)
					if (res.code == 200) {
						this.list = res.data.entityList
					} else {
						$common.showToast(res.msg);
					}
				}).catch((e) => {})

			},
			tijiao: function() {
				// if(t.userInfo.biDianzi < this.entity.typeValue){
				// 	$common.showToast('GHMI不足');
				// 	return;
				// }

				let data = {
					addUserId: t.userInfo.id,
					orderMoney: this.entity.typeValue,
					orderType: this.entity.value,
					orderNum: 1
				}
				this.$fetch.request('orderInfo/save', data, "POST").then((res) => {
					console.info(res)
					if (res.code == 200) {
						console.info("预约成功")
						t.hideModal()
						t.isShowModal = ''
						// $common.showToast("注册成功",1);

					} else {
						$common.showToast(res.msg);
					}
				}).catch((e) => {})
			},
			getUserByToken() {
				let data = {
					username: t.userName,
					password: t.password,
				}
				t.$fetch.request('auth/getUserByToken', data).then((res) => {
					console.info(res)
					if (res.code == 200) {
						console.info("获取getUserByToken成功")
						$common.setUser(res.data.userInfo);

					} else {
						fetch.toast(res.message)
					}
				}).catch((e) => {})
			},
			modalChoose: function(item) {
				// this.$i18n.locale = item.value
				// $common.localSave('local', item.value);
				// this.hideModal();
				this.entity = item
				this.isShowModal = 'show'
			},
			hideModal(e) {
				this.modalName = null
			},
			chanageShowModal: function() {
				this.isShowModal = !this.isShowModal;
			},
		}
	}
</script>

<style>
	uni-page-body {
		height: 100%;
		background-color: #061C2A;
	}

	.flex-sub {
		text-align: center;
	}
</style>
